/**
 * Created by lyf on 2017/6/14.
 */
'use strict'

const uuidV1 = require ('uuid');

const INFO = "info";
const WARN = "warn";
const ERROR = "error";

module.exports = {
    info : function ( log  ) {

        this.output(log , INFO);
    },

    warn : function ( log ) {
        this.output(log, WARN);
    },

    error : function ( log ) {
        this.output(log , ERROR);
    },

    output : function ( log = {} , level ) {
        log.tags = log.tags || [];
        log.meta = log.meta || {};
        log.meta.logId = uuidV1();
        log.level = level;
        log.meta.timestamp = new Date().getTime();
        console[level](JSON.stringify(log));

    }
}
